package com.zxx.googlemap.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.zxx.googlemap.R;

/**
 * https://github.com/zhpanvip/BannerViewPager
 *
 * @author zqq on 2020/2/27.
 */
public class HomeFragment extends Fragment {

    private int type;
    private TextView textView;

    //
    public static HomeFragment getInstance(int type) {
        HomeFragment homeFragment = new HomeFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("aaaa", type);
        homeFragment.setArguments(bundle);
        Log.e("Tag--", "getInstance");
        return homeFragment;
    }

    @Nullable

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Log.e("Tag-2-", "onCreateView");
        return inflater.inflate(R.layout.fragment_home, container, false);
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.e("Tag-1-", "onCreate");

        Bundle bundle = getArguments();
        if (bundle != null) {
            type = bundle.getInt("aaaa");
        }
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Log.e("Tag-4-", "onActivityCreated");

    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        Log.e("Tag-3-", "onViewCreated");

        textView = view.findViewById(R.id.tv_fragment);

        textView.setText(String.valueOf(type));
        textView.setBackgroundColor(Color.green(200));
    }
}
